﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.commands {
    import flash.events.*;
    import reprise.events.*;

    public class AbstractAsynchronousCommand extends AbstractCommand implements IAsynchronousCommand {

        protected var m_isExecuting:Boolean;
        protected var m_isCancelled:Boolean;

        protected function notifyComplete(_arg1:Boolean):void{
            m_isExecuting = false;
            m_didSucceed = _arg1;
            dispatchEvent(new CommandEvent(Event.COMPLETE, _arg1));
        }
        public function isCancelled():Boolean{
            return (m_isCancelled);
        }
        public function isExecuting():Boolean{
            return (m_isExecuting);
        }
        override public function execute(... _args):void{
            if (m_isExecuting){
                return;
            };
            m_isExecuting = true;
            m_isCancelled = false;
        }
        public function cancel():void{
            m_isExecuting = false;
            m_isCancelled = true;
            dispatchEvent(new CommandEvent(Event.CANCEL));
        }
        public function reset():void{
            if (m_isExecuting){
                cancel();
            };
            m_isCancelled = false;
            m_isExecuting = false;
        }

    }
}//package reprise.commands 
